import os.path
import time
import unittest
from HTMLTestRunner import HTMLTestRunner

if __name__ == "__main__":
    suite = unittest.TestLoader().discover('.', 'test.py')
    base_dir = os.path.dirname(os.path.realpath(__file__))
    print(base_dir)
    dir_path = base_dir + "\\result\\"
    now = time.strftime("%Y-%m-%d %H_%M_%S")
    report_path = dir_path + now + "result.html"
    with open(report_path, 'wb') as f:
        runner = HTMLTestRunner(stream=f, verbosity=2, title="用户测试报告", description="html测试")
        runner.run(suite)